package com.eascs.admin.o2o.loan.dao;

import java.util.List;

import org.springframework.stereotype.Repository;

import com.eascs.admin.common.dao.BaseOaDao;
import com.eascs.app.log.Logger;
import com.eascs.app.log.LoggerFactory;

/**
 * 
 * 旧系统贷款次数统计类
 *
 */
@Repository
public class O2oNumDao extends BaseOaDao {
	private final Logger logger = LoggerFactory.getLogger(O2oNumDao.class);
	/**
	 * 统计贷款次数
	 * @param type
	 * @param idcard
	 * @return
	 */
	public int getLoanapplyNum(String idcard,String type) {
		int num=0;
		StringBuffer sql = new StringBuffer();
		sql.append("select count(1)from eadb.o2o_refund c ");
		sql.append("where c.BILLSTATUS in ('RUN', 'CLO') ");
		sql.append("and c.loanapplyno in ( ");
		sql.append("select l.loanapplyno from eadb.o2o_loaner l ");
		sql.append("where l.idcard = ? and l.IDCARDTYPE= ?)");
		num=this.oaJdbcSession.findInteger(sql.toString(), idcard,type);
		logger.info("老系统贷款"+num+"次数");
		return num;
	}
	/**
	 * 连接  老系统 联想员工
	 * @param name
	 * @return
	 */
	public List<Object[]> getOperatorList(String name) {
		String sql = "SELECT EMPLOYEENO, EMPLOYEENAMECN, CONCAT(EMPLOYEECODE,EMPLOYEEACCOUNT)  FROM eadb.HR_EMPLOYEE WHERE 1=1  AND EMPLOYEENAMECN LIKE ? and rownum <=10 ORDER BY  EMPLOYEENO DESC ";
		return this.findObjectsList(sql, "%" + name + "%");
	}
	/**
	 * 连接  老系统 获得工作省份
	 * @param name
	 * @return
	 */
	public List<Object[]> getOperatorWorkeara(String demandUserid) {
		String sql = "SELECT workeara FROM eadb.HR_EMPLOYEE WHERE 1=1  AND EMPLOYEENO = ?";
		return this.findObjectsList(sql, demandUserid);
	}
}
